home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / aplibs91.zip / 2ERRORS.BAS next >
BASIC Source File  |  1991-04-10  |  4KB  |  115 lines

  1.  
  2. '                 DUMMY FILE WITH ERRORS -- TO TEST THE
  3. '                    POWER-BASIC - QEDIT INTERFACE
  4.  
  5. ' (Don't fix the errors now, dummy! Just exit QEdit and let it try to compile.
  6. '  After the first error is located by your computer, then fix it and exit
  7. '   again. It should compile successfully and bomb during execution (can you
  8. '     guess where ... ?? )
  9.  
  10.                          $COMPILE EXE
  11.                          $ERROR ALL ON
  12.                          $OPTION CNTLBREAK ON
  13.                          DEFINT A-Z
  14. %False = 0
  15. %True = NOT %False
  16.  
  17.  SourceFile$ = "2ERRORS.BAS"
  18.  SourceDir$ = "." '                          set up error handling
  19.  RDisk$ = "."  '         temp files will go in current dir (".") --
  20. '                                                         change if you wish ...
  21.  GoToSourceFile = %True '                 if you use QEdit, set this var as
  22.  ON ERROR GOTO Oops2 '                     true and you'll get automatic
  23.  '                                        search for runtime errors when
  24.  '                                        working from the command line --
  25.  '                                        just like you do in the PB environment
  26.  
  27.  
  28.  ' code
  29.  ' more code
  30.  ' more code
  31.  ' more code
  32.  ' more code
  33.  ' more code
  34.  ' more code
  35.  ' more code
  36.  
  37.  
  38.  CLS
  39.  
  40.  
  41.  'THIS IS AN ERROR
  42.  
  43.  A$ = 0
  44.  
  45.  LOCATE 3, 1, 0
  46.  
  47.  PRINT "          ┌───────────────────────────────────────────┐"
  48.  PRINT "          │                                           │"
  49.  PRINT "          │     2ERRORS.EXE IS ABOUT TO BOMB ...      │"
  50.  PRINT "          │                                           │"
  51.  PRINT "          └───────────────────────────────────────────┘"
  52.  PRINT
  53.  
  54.  DELAY 1
  55.  PLAY "O3 T180 MS E8 E4 E4 < B8 > C#4 < A4 P4 > A8"
  56.  
  57.  ' more code
  58.  ' more code
  59.  ' more code
  60.  ' more code
  61.  ' more code
  62.  ' more code
  63.  ' more code
  64.  
  65.   LOCATE 0,0
  66.  
  67.  PRINT "HELLO"
  68.  END
  69.  
  70. SUB BufferStuffer (M$)
  71.  IF LEN (M$) > 15 THEN PLAY "O2 E32 P8 O1 C4": M$ = "COMMAND"+CHR$(255)+"2 LONG"
  72.  L = LEN (M$)
  73.  DEF SEG = 0
  74.  POKE 1050, 30
  75.  POKE 1052, 30 + 2 * L
  76.  FOR I = 1 TO L
  77.    POKE 1052 + 2*I, ASCII (MID$ (M$,I,1))
  78.  NEXT
  79. END SUB
  80.  
  81.  
  82. Oops2:
  83. '                     ERROR HANDLING SUBROUTINE
  84. '                      =======================
  85.  
  86.  DO: LOOP UNTIL INKEY$ = "" '                    first purge the keyboard buffer
  87. '                                               for all other errors we notify
  88.      PLAY "ML O0 C16 D64" '                     user and quit ... UNLESS you set
  89.      PRINT " OOPS! UNABLE TO CONTINUE. ERROR";ERR;" AT ADDRESS ";ERADR;"     "
  90.      IF GoToSourceFile THEN '                 this triggers the ERFIND sequence
  91.        CLS
  92.        IF DIR$ (RDisk$ + "GETERR.&BA") <> "" THEN KILL RDisk$ + "GETERR.&BA"
  93.        IF DIR$ (RDisk$ + "GETERR.BAT") <> "" THEN
  94.          NAME RDisk$ + "GETERR.BAT" AS RDisk$ + "GETERR.&BA"
  95.        END IF
  96.        OutBat = FREEFILE
  97.        OPEN RDisk$ + "GETERR.BAT" FOR OUTPUT AS #OutBat ' create output bat file
  98.        A$ = "@echo off"
  99.        PRINT #OutBat, A$
  100.        A$ = "cd " + SourceDir$
  101.        PRINT #OutBat, A$
  102.        A$ = "error " + STR$ (ERR) '                this calls ERROR.EXE to tell
  103.        PRINT #OutBat, A$ '                          you what went wrong ...
  104.        A$ = "pbc /re" + LTRIM$ (STR$ (ERADR)) + " " + SourceFile$
  105.        PRINT #OutBat, A$
  106.        A$ = "ERFIND " + SourceFile$
  107.        PRINT #OutBat, A$
  108.        CLOSE #OutBat
  109.        CALL BufferStuffer (RDisk$ + "GETERR" + CHR$(13)) '   and run it
  110.     END IF
  111.     END 1 '  ┌──────────────────────────────────────────────────────────┐
  112.           '  │    I downloaded ERROR.EXE, by Rodney Jones, from the     │
  113.  RESUME   '  │   CompuServe PCVEN-B forum. A good work, very helpful !  │
  114.           '  └──────────────────────────────────────────────────────────┘
  115.